package Compation;

public class numSteps {
    public static void main(String[] args) {
        String s = "1101";
        System.out.println(new numSteps().calStep(13));
    }

    public int numSteps(String s) {
        if (s == "1") {
            return 0;
        }
        int num = Integer.parseInt(s, 2);
        int res = calStep(num);
        return res;
    }

    public int calStep(int num){
        int res = 0;
        while (num != 1) {
            if (num % 2 == 1) {
                num += 1;
            } else {
                num = num / 2;
            }
            res++;
        }
        return res;
    }

    public int convertNum(String s) {
        int res = 0;
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            int num = s.charAt(i) - '0';
            res += Math.pow(2, count) * num;
            count++;
        }
        return res;
    }
}
